package com.lovo.service.impl;

import com.lovo.bean.ClassBean;
import com.lovo.bean.StudentBean;
import com.lovo.dao.IStudentDAO;
import com.lovo.service.IClassService;
import com.lovo.service.IStudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class StudentServiceImpl implements IStudentService {
    @Resource
    private IStudentDAO studentDAO;
    @Resource
    private IClassService classService;
    public StudentServiceImpl(IStudentDAO studentDAO){
        this.studentDAO = studentDAO;
    }
    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    public void add(StudentBean studentBean) {
//        log.info("进入方法add");
        studentDAO.insert(studentBean);
        try{
            classService.add(new ClassBean(null,"J179"));
        }catch (Exception e){

        }
//        int a = 100 / 0;


    }

    @Override
    public List selectAll() {
        return studentDAO.selectAll();
    }

}
